<?
if( isset($_GET['name']) )
	$name = $_GET['name'];
else
	$name = $_POST['name'];

$user = getLdapUser($conn,$name);
if ($user[0]['uidnumber'][0] == 0) {
	// kan inte ta bort userid nummer 0
	sleep(0);
        exit(0);
} else {
	exec("/usr/sbin/smbldap-userdel -r \"$name\" 2> /dev/null", $out, $ret);

	//email aliases
	$sr=ldap_search($conn, "ou=Aliases,".$GLOBALS["dc"], "(rfc822MailMember=".$_GET["name"].")");
	$aliases = ldap_get_entries($conn, $sr);
	$count = count($aliases)-1;
	for ($i=0; $i < $count; $i++) {
		ldap_delete($conn,"cn=".$aliases[$i]["cn"][0].",ou=Aliases,".$GLOBALS["dc"]);
	}

}
?>
